package com.movitech.mobile.cz.base.modules.activiti.controller;


import com.movitech.mobile.cz.base.modules.activiti.service.*;
import com.movitech.mobile.cz.base.modules.controller.RestReturnResult;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 采购流程配置
 * </p>
 *
 * @author Movitech Mobile
 * @since 2018-03-15
 */
@RestController
@RequestMapping("/v1/wFlowConfig")
@Api(value = "采购流程配置", description = "采购流程配置")
public class AProcessConfigController {
    @Autowired
    private ActivitiHistoryService activitiHistoryService;
    @Autowired
    private ActivitiProcessService activitiProcessService;
    @Autowired
    private ActivitiRepositoryService activitiRepositoryService;
    @Autowired
    private ActivitiRuntimeService activitiRuntimeService;
    @Autowired
    private ActivitiService activitiService;
    @Autowired
    private ActivitiTaskService activitiTaskService;
    @Autowired
    private AProcessConfigService aProcessConfigService;
    @Autowired
    private AProcessDefinitionConfigService aProcessDefinitionConfigService;
    @Autowired
    private AProcessNodeConfigService aProcessNodeConfigService;
    @Autowired
    private AProcessNodeDefinitionConfigService aProcessNodeDefinitionConfigService;
    @Autowired
    private AProcessNodeLineConfigService aProcessNodeLineConfigService;
    @Autowired
    private AProcessNodeLineDefinitionConfigService aProcessNodeLineDefinitionConfigService;

    @GetMapping("/genAndDeploy")
    @ResponseBody
    public RestReturnResult genAndDeploy(String processDefinitionConfigId, Integer actionType) {
        try {
            RestReturnResult restReturnResult = RestReturnResult.success();
            activitiProcessService.doGenerateAndDeployBpmByDefinitions(processDefinitionConfigId, actionType, null);
            return restReturnResult;
        } catch (Exception e) {
            e.printStackTrace();
            RestReturnResult restReturnResult = RestReturnResult.error();
            restReturnResult.setMsg(e.getMessage());
            return restReturnResult;
        }
    }

}

